package com.yunti.springboot.controller;

import com.yunti.springboot.annotation.Log;
import com.yunti.springboot.service.ScoreService;
import com.yunti.springboot.vo.Result;
import com.yunti.springboot.vo.req.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/score")
public class ScoreController {
    @Resource
    private ScoreService scoreService;

    @Log
    @PostMapping("/updateScore")
    public Result updateScore(@RequestBody UpdateScoreReq updateScoreReq){
//        return scoreService.getConfig(getConfigReq);
        return scoreService.updateScore(updateScoreReq);
    }

    /**
     *下载成绩表
     * @param scoreTableReq 成绩列表
     * @return
     */
    @PostMapping("/downloadScore")
    public void downloadScore(@RequestBody ScoreTableReq scoreTableReq, HttpServletResponse response){
        scoreService.downloadScore(scoreTableReq,response);
    }


    /**
     * 获取班级概览数据
     * @param classOverViewReq 成绩列表
     * @return
     */
    @PostMapping("/getClassOverView")
    public Result getClassOverView(@RequestBody ClassOverViewReq classOverViewReq){
        return scoreService.getClassOverView(classOverViewReq);
    }


    /**
     * 学生成绩汇总
     * @param req
     * @return
     */
    @PostMapping("/getScoreCollect")
    public Result getScoreCollect(@RequestBody ScoreCollectReq req){
        return scoreService.getScoreCollect(req);
    }



    /**
     * 下载成绩汇总
     * @param req
     * @return
     */
    @PostMapping("/downScoreCollect")
    public Result downScoreCollect(@RequestBody ScoreCollectReq req,HttpServletResponse response){
        return scoreService.downScoreCollect(req,response);
    }
}
